﻿@{
    ViewBag.Title = "事件信息";
    Layout = "~/Areas/IM/Views/Shared/_Layout.cshtml";
}
@section scripts{
    <script src="../Scripts/jquery.AnkeExtend.js"> </script>     
    <script type="text/javascript">
    //页面动态改动
    $(window).resize(function () {
        $.setGridWithSearchBar("#TableForm", "#SearchBar", "#grid");
    });

    //页面初始化
    $(document).ready(function () {
        DisableBackspace();

        $('#editWindow').window('close'); // 默认隐藏查看详细信息窗口

        //取事件类型
        $.EUIcombobox("#eventType", {
            url: '@Url.Content("~/DD/EventInfo/GetEventType/")',
                valueField: 'ID',
                textField: 'Name',
                editable: false,
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            });
            //取所属分中心的下拉框的值
            $("#centerID").combobox({
                url: '@Url.Content("~/BB/AllDictionary/GetCenterName")',
                valueField: 'ID',
                textField: 'Name',
                editable: false,
                multiple: true,
                prompt: '--请选择--',
                onSelect: function (rec) {
                    var ids = $('#centerID').combobox('getValues');
                    //根据分中心取分站
                    $("#station").combobox({
                        url: '@Url.Content("~/BB/AllDictionary/GetSationName?centerID=")' + ids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#stationID').combobox('getValues');
                            var sids = $('#stationID').combobox('getValues');
                            //根据分站取车辆
                            $("#ambulanceCode").combobox({
                                url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                                method: 'POST',
                                valueField: 'ID',
                                textField: 'Name',
                                multiple: true,
                                editable: false,
                                onSelect: function () {
                                    $('#ambulanceCode').combobox('getValues')
                                },
                                onUnselect: function () {
                                    $('#ambulanceCode').combobox('getValues')
                                }
                            });
                        },
                        onUnselect: function () {
                            $('#stationID').combobox('getValues');
                            var sids = $('#stationID').combobox('getValues');
                            //根据分站取车辆
                            $("#actualNumber").combobox({
                                url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                                method: 'POST',
                                valueField: 'ID',
                                textField: 'Name',
                                multiple: true,
                                editable: false,
                                onSelect: function () {
                                    $('#ambulanceCode').combobox('getValues')
                                },
                                onUnselect: function () {
                                    $('#ambulanceCode').combobox('getValues')
                                }
                            });
                        }
                    });
                    $("#stationID").combobox('clear');
                    $("#ambulanceCode").combobox('clear');
                },
                onUnselect: function (rec) {
                    var ids = $('#centerID').combobox('getValues');
                    //根据分站取车辆
                    $("#station").combobox({
                        url: '@Url.Content("~/BB/AllDictionary/GetSationName?centerID=")' + ids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#stationID').combobox('getValues');
                            var sids = $('#stationID').combobox('getValues');
                            //根据分站取车辆
                            $("#ambulanceCode").combobox({
                                url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                                method: 'POST',
                                valueField: 'ID',
                                textField: 'Name',
                                multiple: true,
                                editable: false,
                                onSelect: function () {
                                    $('#ambulanceCode').combobox('getValues')
                                },
                                onUnselect: function () {
                                    $('#ambulanceCode').combobox('getValues')
                                }
                            });
                            $("#ambulanceCode").combobox('clear');
                        },
                        onUnselect: function () {
                            $('#stationID').combobox('getValues');
                            var sids = $('#stationID').combobox('getValues');
                            //根据分站取车辆
                            $("#ambulanceCode").combobox({
                                url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                                method: 'POST',
                                valueField: 'ID',
                                textField: 'Name',
                                multiple: true,
                                editable: false,
                                onSelect: function () {
                                    $('#ambulanceCode').combobox('getValues')
                                },
                                onUnselect: function () {
                                    $('#ambulanceCode').combobox('getValues')
                                }
                            });
                            $("#ambulanceCode").combobox('clear');
                        }
                    });
                    $("#stationID").combobox('clear');
                    $("#ambulanceCode").combobox('clear');
                }

            });

            var centers = $('#centerID').combobox('getValues');
            $("#stationID").combobox({
                url: '@Url.Content("~/BB/AllDictionary/GetSationName?centerID=")' + centers,
                method: 'POST',
                valueField: 'ID',
                textField: 'Name',
                multiple: true,
                editable: false,
                prompt: '--请选择--',
                onSelect: function () {
                    $('#stationID').combobox('getValues');
                    var sids = $('#stationID').combobox('getValues');
                    //根据分中心取分站
                    $("#ambulanceCode").combobox({
                        url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#ambulanceCode').combobox('getValues')
                        },
                        onUnselect: function () {
                            $('#ambulanceCode').combobox('getValues')
                        }
                    });
                },
                onUnselect: function () {
                    $('#stationID').combobox('getValues');
                    var ids = $('#stationID').combobox('getValues');
                    //根据分站取车辆
                    $("#ambulanceCode").combobox({
                        url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + ids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#ambulanceCode').combobox('getValues')
                        },
                        onUnselect: function () {
                            $('#ambulanceCode').combobox('getValues')
                        }
                    });

                }
            });
            //取车辆号码
            $.EUIcombobox("#ambulanceCode", {
                url: '@Url.Content("~/DD/EventInfo/GetAmbulanceCode/")',
            valueField: 'ID',
            textField: 'Name',
            editable: true,
            OneOption: [{
                ID: "",
                Name: "--请选择--"
            }]
        });
        //取调度员
        $.EUIcombobox("#dispatcher", {
            url: '@Url.Content("~/DD/EventInfo/GetDispatcher/")',
            valueField: 'ID',
            textField: 'Name',
            editable: true,
            OneOption: [{
                ID: "",
                Name: "--请选择--"
            }]
        });
        $('#start').datetimebox('setValue', '@ViewData["start"]');
        $('#end').datetimebox('setValue', '@ViewData["end"]');
        bindGrid();
        $.setGridWithSearchBar("#TableForm", "#SearchBar", "#grid");
    })

    function bindGrid() {
        $('#grid').datagrid({
            width: 'auto',
            height: 'auto',
            fitColumns: true,
            striped: true,
            singleSelect: true,
            url: '@Url.Content("~/DD/EventInfo/DataLoad")',
            loadMsg: '数据加载中请稍后……',
            pagination: true,//启用分页
            rownumbers: true,//显示页码
            pageSize: 15,//设置 页容量
            pageList: [10, 15, 20],//设置 页容量下拉框
            queryParams: {
                start: $('#start').datetimebox('getValue'),
                end: $('#end').datetimebox('getValue'),
                contactTel: $('#contactTel').textbox('getValue'),
                telephoneNumber: $('#telephoneNumber').textbox('getValue'),
                localAddress: $('#localAddress').textbox('getValue'),
                patientName: $('#patientName').textbox('getValue'),
                sendAddress: $('#sendAddress').textbox('getValue'),
                dispatcher: $('#dispatcher').combobox('getValue'),
                eventType: $('#eventType').combobox('getValue'),
                centerID: $("#centerID").combobox('getValues').join(','),
                stationID: $('#stationID').combobox('getValues').join(','),
                ambulanceCode: $('#ambulanceCode').combobox('getValues').join(',')
            },
            columns: [[
               { title: '呼救电话', field: 'callPhone', width: '10%', align: "center", sortable: false },
               { title: '现场地址', field: 'localAdr', width: '26%', align: "center", sortable: false },
               { title: '送往地点', field: 'sendAdr', width: '12%', align: "center", sortable: false },
               //{ title: '所派车辆', field: 'dispatchedCar', width: '10%', align: "center", sortable: false },
               { title: '患者姓名', field: 'pName', width: '6%', align: "center", sortable: false },
               { title: '主诉', field: 'mainSuit', width: '9%', align: "center", sortable: false },
               { title: '受理时刻', field: 'firstAcceptTime', width: '12%', align: "center", sortable: false },
               { title: '调度员', field: 'firstDispatcher', width: '5%', align: "center", sortable: false },
               { title: '受理次数', field: 'acceptTimes', width: '5%', align: "center", sortable: false },
               { title: '呼救时刻', field: 'callTime', width: '12%', align: "center", sortable: false },
               { title: '事件编码', field: 'EventCode', width: '10%', align: "center", sortable: false, hidden: true },
            ]],
            toolbar: [
                {
                    id: 'btnView',
                    text: '<span style="color:red;font-size:large">查看详细</span>',
                    iconCls: 'icon-redo',
                    handler: function () {
                        var selected = $('#grid').datagrid('getSelected');
                        if (selected) {
                            window.open('@Url.Content("~/DD/AcceptEvent/AcceptEventTaskList?EventCode=")' + selected.EventCode);
                        } else {
                            $.messager.alert('提示', '请选择数据行', 'info', function () {
                            });
                        }
                    }
                }
            ]
        })
        $.setGridWithSearchBar("#TableForm", "#SearchBar", "#grid");
    }
    //查询
    function reSearch() {
        $('#grid').datagrid({
            pageNumber:1,//点击查询返回第一页
            queryParams: {
                start: $('#start').datetimebox('getValue'),
                end: $('#end').datetimebox('getValue'),
                contactTel: $('#contactTel').textbox('getValue'),
                telephoneNumber: $('#telephoneNumber').textbox('getValue'),
                localAddress: $('#localAddress').textbox('getValue'),
                patientName: $('#patientName').textbox('getValue'),
                sendAddress: $('#sendAddress').textbox('getValue'),
                dispatcher: $('#dispatcher').combobox('getValue'),
                eventType: $('#eventType').combobox('getValue'),
                centerID: $('#centerID').combobox('getValues').join(','),
                stationID: $('#stationID').combobox('getValues').join(','),
                ambulanceCode: $('#ambulanceCode').combobox('getValues').join(',')
            }
        })
    }
    </script>
}
<div id="TableForm" class="easyui-layout" style="width:auto; height: auto; margin-left: auto; margin-right: auto">
    <div data-options="region:'center',title:'事件信息',iconCls:'icon-custom-Entry'">
        <div id="SearchBar" data-options="region:'center'" style="overflow: hidden; padding: 10px">
            <table style="width:99%" cellpadding="0" cellspacing="5" border="0">
                <tr>
                    <td align="right" valign="middle" width="9%">受理时刻：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="start" class="easyui-datetimebox" value=@ViewData["start"] style="width:150px" data-options="editable:false" />
                    </td>
                    <td align="right" valign="middle" width="9%">至：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="end" class="easyui-datetimebox" value=@ViewData["end"] style="width:150px" data-options="editable:false" />
                    </td>
                    <td align="right" valign="middle" width="9%">事件类型：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="eventType" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">患者姓名：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="patientName" class="easyui-textbox" style="width:150px" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" width="9%">分中心：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="centerID" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">分站：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="stationID" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">车辆号码：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="ambulanceCode" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">调度员：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="dispatcher" class="easyui-combobox" style="width:150px" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" width="9%">现场地址：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="localAddress" class="easyui-textbox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">送往地点：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="sendAddress" class="easyui-textbox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">呼救电话：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="telephoneNumber" class="easyui-textbox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">联系电话：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="contactTel" class="easyui-textbox" style="width:150px" />
                    </td>
                    <td align="center" valign="middle" width="11%">
                        <a href="javascript:void(0)" id="btnsearch" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reSearch()">查询</a>
                    </td>
                </tr>
            </table>
        </div>
        <div data-options="region:'center'" style="background: #fafafa; overflow: hidden">
            <table id="grid"></table>
        </div>
    </div>
</div>

